<?php

/**

 * Application level View Helper

 *

 * This file is application-wide helper file. You can put all

 * application-wide helper-related methods here.

 *

 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)

 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)

 *

 * Licensed under The MIT License

 * For full copyright and license information, please see the LICENSE.txt

 * Redistributions of files must retain the above copyright notice.

 *

 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)

 * @link          http://cakephp.org CakePHP(tm) Project

 * @package       app.View.Helper

 * @since         CakePHP(tm) v 0.2.9

 * @license       http://www.opensource.org/licenses/mit-license.php MIT License

 */



App::uses('Helper', 'View');



/**

 * Application helper

 *

 * Add your application-wide methods in the class below, your helpers

 * will inherit them.

 *

 * @package       app.View.Helper

 */

class AppHelper extends Helper {

		public $helpers = array(

		'Html',

		'Form',

		'Session',

		'Js',

	);

    public function js() {
        $shop = array();
        $shop['basePath'] = Router::url('/');
        $shop['params'] = array(
            'controller' => $this->params['controller'],
            'action' => $this->params['action'],
        );
        return $this->Html->scriptBlock('var Shop = ' . $this->Js->object($shop) . ';');
    }


	function fix_url($url=null) {

		if(empty($url)) return '#';

		return (substr($url, 0, 7) == 'http://' || substr($url, 0, 8) == 'https://')

			? $url 

			: 'http://'.$url;

	}

}

